{extend name="$base" /}
{block name="resources"}{/block}
{block name="main"}
<div class="set-style">
	<dl>
		<dt>用户名:</dt>
		<dd>
			<span class="js-user-name">{$info['user_name']} &nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserName()">修改</a></span>
			<span class="js-user-name-input" style="display:none;">
				<input id="user_name" type="text" value="{$info['user_name']}" class="input-common" />
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserNameConfirm()">确定</a>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserNameCancel()">取消</a>
			</span>
		</dd>
	</dl>
	<dl>
		<dt>头像:</dt>
		<dd>
			<div class="class-logo">
				<p>
					{if condition="$info['user_headimg'] eq ''"}
					<img id="imglogo">
					{else/}
					<img id="imglogo" src="{:__IMG($info['user_headimg'])}">
					{/if}
				</p>
			</div>
			<div class="upload-btn">
				<span>
					<input class="input-file" name="file_upload" id="uploadImg" type="file">
					<input type="hidden" id="logo" value="{$info['user_headimg']}"/>
				</span>
				<p><i class="fa fa-cloud-upload"></i>上传图片</p>
			</div>
			<p class="hint"><span style="color:orange;">建议使用宽100像素-高100像素内的GIF或PNG透明图片；点击下方"提交"按钮后生效。</span></p>
		</dd>
	</dl>
	<dl>
		<dt>手机:</dt>
		<dd>
			<span class="js-user-tel">{$info['user_tel']} &nbsp;&nbsp;
				<a href="javascript:;" onclick="updateUserTel()" style='{if condition="$info['user_tel_bind'] eq 1"}display:none;{/if}'>修改</a>&nbsp;&nbsp;
				{if condition="$info['user_tel'] neq ''"}
				<a class="user_tel_bind" href="javascript:;" onclick="userTelBind()" style='{if condition="$info['user_tel_bind'] eq 1"}display:none;{/if}'>绑定</a>
				{/if}
				<a class="remove_user_tel_bind" href="javascript:;" onclick="removeUserTelBind()" style='{if condition="$info['user_tel_bind'] eq 0"}display:none;{/if}'>解绑</a>
			</span>
			<span class="js-user-tel-input" style="display:none;">
				<input class="input-common" id="user_tel" type="text" value="{$info['user_tel']}"/>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserTelConfirm()">确定</a>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserTelCancel()">取消</a>
			</span>
		</dd>
	</dl>
	<dl>
		<dt>邮箱:</dt>
		<dd>
			<span class="js-user-email">{$info['user_email']} &nbsp;&nbsp;
				<a href="javascript:;" onclick="updateUserEmail()" style='{if condition="$info['user_email_bind'] eq 1"}display:none;{/if}'>修改</a>&nbsp;&nbsp;
				{if condition="$info['user_email'] neq ''"}
				<a class="user_email_bind" href="javascript:;" onclick="userEmailBind()" style='{if condition="$info['user_email_bind'] eq 1"}display:none;{/if}'>绑定</a>
				{/if}
				<a class="remove_user_email_bind" href="javascript:;" onclick="removeUserEmailBind()" style='{if condition="$info['user_email_bind'] eq 0"}display:none;{/if}'>解绑</a>
			</span>
			<span class="js-user-email-input" style="display:none;">
				<input id="user_email" class="input-common" type="text" value="{$info['user_email']}"/>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserEmailConfirm()">确定</a>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserEmailCancel()">取消</a>
			</span>
		</dd>
	</dl>
	<dl>
		<dt>QQ:</dt>
		<dd>
			<input id="user_qq" class="input-common w200" type="text" value="{$info['user_qq']}" />
		</dd>
	</dl>
	<dl>
		<dt>社交账号:</dt>
		<dd>
			<span style='{notempty name="info['qq_openid']"}display:none;{/notempty}'>
				<a href="{:__URL('APP_MAIN/login/oauthlogin?type=QQLOGIN')}"><i class="fa fa-qq"></i> 绑定QQ</a>
			</span>
			<span style='{empty name="info['qq_openid']"}display:none;{/empty}'>
				{notempty name="info['qq_openid']"}
				<img src="{$info['qq_info_array']['figureurl_qq_1']}">
				{/notempty}
				<a href="javascript:removeUserEmailBind();"> 解绑</a>
			</span>
		</dd>
	</dl>
	<dl>
		<dt></dt>
		<dd><button class="btn-common btn-big" onclick="setUserBasicAjax();">提交</button></dd>
	</dl>
</div>
<script src="__STATIC__/js/ajax_file_upload.js" type="text/javascript"></script>
<script src="__STATIC__/js/file_upload.js" type="text/javascript"></script>
<script>
function setUserBasicAjax(){
	var user_headimg = $("#logo").val();
	var user_qq = $("#user_qq").val();
	$.ajax({
		type:"post",
		url:"{:__URL('ADMIN_MAIN/auth/userdetail')}",
		data:{
			'user_headimg':user_headimg,
			'user_qq':user_qq,
		},
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/auth/userdetail?type=basic')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}

//显示 修改邮箱
function updateUserEmail(){
	$(".js-user-email").hide();
	$(".js-user-email-input").show();
}

//取消
function updateUserEmailCancel(){
	$(".js-user-email").show();
	$(".js-user-email-input").hide();
}

//修改 用户 邮箱
function updateUserEmailConfirm(){
	var user_email = $("#user_email").val();
	$.ajax({
		type:"post",
		url:"{:__URL('ADMIN_MAIN/auth/modifyuseremail')}",
		data:{'user_email':user_email},
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}

//解除 会员邮箱绑定
function removeUserEmailBind(){
	$.ajax({
		type:"post",
		url:"{:__URL('ADMIN_MAIN/auth/removeuseremailbind')}",
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}

//会员邮箱 绑定
function userEmailBind(){
	$.ajax({
		type:"post",
		url:"{:__URL('ADMIN_MAIN/auth/useremailbind')}",
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}

//显示手机号
function updateUserTel(){
	$(".js-user-tel").hide();
	$(".js-user-tel-input").show();
}

//取消
function updateUserTelCancel(){
	$(".js-user-tel").show();
	$(".js-user-tel-input").hide();
}

//修改 用户手机号
function updateUserTelConfirm(){
	var user_tel = $("#user_tel").val();
	$.ajax({
		type:"post",
		url:"{:__URL('ADMIN_MAIN/auth/modifyuserTel')}",
		data:{'user_tel':user_tel},
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}

//解除 会员手机绑定
function removeUserTelBind(){
	$.ajax({
		type:"post",
		url:"{:__URL('ADMIN_MAIN/auth/removeusertelbind')}",
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}

//会员手机绑定
function userTelBind(){
	$.ajax({
		type:"post",
		url:"{:__URL('ADMIN_MAIN/auth/usertelbind')}",
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}

//解除 用户 qq 绑定
function removeUserQQBind(){
	$( "#dialog" ).dialog({
		buttons: {
			"确定,#0059d6,#fff": function() {
			$(this).dialog('close');
			$.ajax({
				type:"post",
				url:"{:__URL('ADMIN_MAIN/auth/removeuserqqbind')}",
				success:function (data) {
					if (data["code"] > 0) {
						showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/auth/userdetail')}");
					}else{
						showMessage('error', data["message"]);
					}
				}
			});
		},
		"取消": function() {
			$(this).dialog('close');
		}
	},
	contentText:"确定解除绑定吗？"
	});
}

//图片上传
$("#uploadImg").live("change",function(){
	var data = { 'file_path' : "auth" };
	uploadFile({
		url: __URL(ADMINMAIN + '/auth/uploadimage'),
		fileId: "uploadImg",
		data : data,
		callBack: function (res) {
			if (res.code) {
				$("#imglogo").attr("src", __IMG(res.data.path));
				$("#logo").val(res.data.path);
				showTip(res.message, "success");
			} else {
				showTip(res.message, "error");
			}
		}
	});
});

//修改会员用户名显示
function updateUserName(){
	$(".js-user-name").hide();
	$(".js-user-name-input").show();
}

//修改用户名取消
function updateUserNameCancel(){
	$(".js-user-name").show();
	$(".js-user-name-input").hide();
}

//修改用户名提交
function updateUserNameConfirm(){
	var user_name = $("#user_name").val();
	$.ajax({
		type:"post",
		url:"{:__URL('ADMIN_MAIN/auth/modifyusername')}",
		data:{ 'user_name':user_name },
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}
</script>
{/block}